package com.job.Yangmingyu.String0716;

/**
 * @author Yangmingyu
 * @version 1.0
 * @since 2022-07-16 14:55:55
 */
public class StringButter02 {
    public static void main(String[] args) {
        String url="http://localhost:8080/admin/table/tablelist.html";
        StringBuffer sbf=new StringBuffer(url);
        String find="8080",port="9000";
        int index=sbf.indexOf(find);
        //开始下标包括，结束下标不包括
        sbf.replace(index, index+find.length(),port);
        url=sbf.toString();
        System.out.println(url);

        int lastindex=sbf.lastIndexOf("table");
        sbf.delete(lastindex, lastindex+5);
        url=sbf.toString();
        System.out.println(url);//删去了最后一个table

        sbf.insert(4, 's');
        url=sbf.toString();
        System.out.println(url);//第四位插入一个s

        String src="2442";
        StringBuffer sbf2=new StringBuffer("2442");
        String dest=sbf2.reverse().toString();
        if (src.equals(dest)){
            System.out.println("回文");
        }
    }
}